
function initialize(){
(function($){
	//wait for html to load before running script
	$(document).ready(function(){
		//interstitial
		$("#loading-mask")
   		setTimeout( function(){
         $("#loading-mask").fadeOut("fast");
      	}, 2000);
 
		//search box text replace
		 $('input[type=text]').focus(function(){ 
    		if($(this).val() == $(this).attr('defaultValue'))
   			{
      		$(this).css('color','#000').val('');
    		}
  		});
  
  		$('input[type=text]').blur(function(){
    		if($(this).val() == '')
    		{
      		$(this).css('color','#000').val($(this).attr('defaultValue'));
    		} 
  		});
		//load lightbox effect, show <p> tags in there.
		$("a#show-panel").click(function(){ 
		$('#lightbox-panel p').show(); 
		$("#lightbox, #lightbox-panel").fadeIn(300);  
		})  
		$("a.close-panel").css('cursor', 'pointer').click(function(){  
		$("#lightbox, #lightbox-panel").fadeOut(300);  
		})  
		//load sidebar rotator
		$(document).ready(function() {		
		//Load the slideshow
		theRotator();
		$('.rotator').fadeIn(1000);
    	$('.rotator ul li').fadeIn(1000); // tweek for IE
		});
		//load top rotator
		$(document).ready(function() {		
		//Load the slideshow
		thetopRotator();
		$('.toprotator').fadeIn(1000);
    	$('.toprotator ul li').fadeIn(1000); // tweek for IE
		});
		//collapse content blocks on page load
		$('.block .blockcontent').hide();
		$('.staticblockcontent').hide();
		//collapse back button on page load
		$('#backbutton').hide();
		//hide all paragraph content on page load
		$('p').hide();
		//hide the following sections on page load
		$('.cardtext').hide();
		$('.kidstext').hide();
		$('.teenstext').hide();
		$('.adultstext').hide();
		$('.eventonetext').hide();
		$('.eventtwotext').hide();
		$('.eventthreetext').hide();
		$('.healthtext').hide();
		$('.companytext').hide();
		$('.encyclopediastext').hide();
		$('.recommendedtext').hide();
		$('#hours').hide();
		$('#locations').hide();
		$('.yesterdaysbook').hide();
		$('.lastweeksbooks').hide();
			
		//toggling all the content
		$('.block h1.blocktitle').css('cursor', 'pointer').click(function(){
			$(this).parent().children('.blockcontent').slideToggle();	
		});			
		//toggling the  +/- images
		$(".block h1.blocktitle").toggle(
		function(){ 
		 $(this).children('img').attr("src", "images/contract.png");
		 },
		 function(){ 
		 $(this).children('img').attr("src", "images/expand.png");
		 }
);
$("h2").toggle(
		function(){ 
		 $(this).children('img').attr("src", "images/h2contract.png");
		 },
		 function(){ 
		 $(this).children('img').attr("src", "images/h2expand.png");
		 }
);
			//yesterday
			$('#yesterdaysbookh2').css('cursor', 'pointer').click(function(){				  
			$('.yesterdaysbook').slideToggle();
			$('#primary_nav_two').hide(.1, function() {});
			$('#primary_nav_three').hide(.1, function() {});
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_two').show(.1, function() {});
			$('#primary_nav_three').show(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			//last week
			$('#lastweeksbooksh2').css('cursor', 'pointer').click(function(){				  
			$('.lastweeksbooks').slideToggle();
			$('#primary_nav_two').hide(.1, function() {});
			$('#primary_nav_three').hide(.1, function() {});
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_two').show(.1, function() {});
			$('#primary_nav_three').show(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			//animation for upcoming events
			//event one		
			$('#eventone').css('cursor', 'pointer').click(function(){
			$('#eventone').fadeTo("slow", 1);
			$('#eventtwo').fadeTo("slow", 0.1);	
			$('#eventthree').fadeTo("slow", 0.1);
			$('#eventfour').fadeTo("slow", 1);
			$('#eventfive').fadeTo("slow", 0.1);
			$('#eventsix').fadeTo("slow", 0.1);			  
			$(".eventtext").html("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
			$('#primary_nav_three').hide(.1, function() {});
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_three').show(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			//event two
			$('#eventtwo').css('cursor', 'pointer').click(function(){  
			$('#eventone').fadeTo("slow", 0.1);	
			$('#eventtwo').fadeTo("slow", 1);
			$('#eventthree').fadeTo("slow", 0.1);
			$('#eventfour').fadeTo("slow", 1);
			$('#eventfive').fadeTo("slow", 0.1);
			$('#eventsix').fadeTo("slow", 0.1);		  
			$(".eventtext").html("Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?");
			$('#primary_nav_three').hide(.1, function() {});
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_three').show(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			//event three
        	$('#eventthree').css('cursor', 'pointer').click(function(){  
			$('#eventone').fadeTo("slow", 0.1);	
			$('#eventtwo').fadeTo("slow", 0.1);
			$('#eventthree').fadeTo("slow", 1);
			$('#eventfour').fadeTo("slow", 1);
			$('#eventfive').fadeTo("slow", 0.1);
			$('#eventsix').fadeTo("slow", 0.1);			  
			$(".eventtext").html("At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
			$('#primary_nav_three').hide(.1, function() {});
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_three').show(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			
			
			
				
			//animation for kids, teens and adults
			//kids
			$('#kids').css('cursor', 'pointer').click(function(){				  
			$(".kidstext").slideToggle();
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//teens
			$('#teens').css('cursor', 'pointer').click(function(){  
			$('.teenstext').slideToggle();
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//adults
        	$('#adults').css('cursor', 'pointer').click(function(){  
			$('.adultstext').slideToggle();
			$('#primary_nav_four').hide(.1, function() {});
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_four').show(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
			
			//animation for library card page, first the card paragraph
			$('#card').css('cursor', 'pointer').click(function(){				  
			$(".cardtext").slideToggle();
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//then the 'other' parahraph
			$('#other').css('cursor', 'pointer').click(function(){  
			$('#othertext').slideToggle();
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//third choice
        	$('#thirdchoice').css('cursor', 'pointer').click(function(){  
			$('#thirdchoicetext').slideToggle();
			$('#primary_nav_five').hide(.1, function() {});
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_five').show(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//end animation for library card page
			
			//animation for research and reference
			//kids
			$('#health').css('cursor', 'pointer').click(function(){				  
			$(".healthtext").slideToggle();
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//teens
			$('#company').css('cursor', 'pointer').click(function(){  
			$('.companytext').slideToggle();
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			//adults
        	$('#encyclopedias').css('cursor', 'pointer').click(function(){  
			$('.encyclopediastext').slideToggle();
			$('#primary_nav_six').hide(.1, function() {});
			$('#primary_nav_seven').hide(.1, function() {});
			$('#primary_nav_six').show(.1, function() {});
			$('#primary_nav_seven').show(.1, function() {});
			});
			
	});	

//all of the stuff after this is the reset after hitting the back button
$('.revealall').css('cursor', 'pointer').click(function() {
$('#primary_nav_one').slideDown(500, function() {});
$('#primary_nav_two').slideDown(500, function() {});
$('#primary_nav_three').slideDown(500, function() {});
$('#primary_nav_four').slideDown(500, function() {});
$('#primary_nav_five').slideDown(500, function() {});
$('#primary_nav_six').slideDown(500, function() {});
$('#primary_nav_seven').slideDown(500, function() {});
$('#primary_nav_eight').slideDown(500, function() {});
$('#primary_nav_nine').slideDown(500, function() {});
$('.rotator').slideDown(500, function() {});
$('.toprotator').slideDown(500, function() {});
$('.toprotatorspacer').slideDown(500, function() {});
$('#hours').hide();
$('#locations').hide();
$('.block .blockcontent').hide();
$('.staticblockcontent').hide();
$('#backbutton').hide();
//reset the image toggle
$('.blocktitle img').attr("src", "images/expand.png");
$(".block h1.blocktitle").toggle(
		function(){ 
		 $(this).children('img').attr("src", "images/contract.png");
		 },
		 function(){ 
		 $(this).children('img').attr("src", "images/expand.png");
		 }
);
});

})(jQuery);
}



function showhours(){
	$('#hours').show();
	$('#primary_nav_eight .staticblockcontent').show();
	$('#primary_nav_one').slideUp(500, function() {});
	$('#primary_nav_two').slideUp(500, function() {});
	$('#primary_nav_three').slideUp(500, function() {});
	$('#primary_nav_four').slideUp(500, function() {});
	$('#primary_nav_five').slideUp(500, function() {});
	$('#primary_nav_six').slideUp(500, function() {});
	$('#primary_nav_seven').slideUp(500, function() {});
	$('.rotator').slideUp(500, function() {});
	$('.toprotator').slideUp(500, function() {});
	$('.toprotatorspacer').slideUp(500, function() {});
	$('#backbutton').show();
}

function showlocations(){
	$('#locations').show();
	$('#primary_nav_nine .staticblockcontent').show();
	$('#primary_nav_one').slideUp(500, function() {});
	$('#primary_nav_two').slideUp(500, function() {});
	$('#primary_nav_three').slideUp(500, function() {});
	$('#primary_nav_four').slideUp(500, function() {});
	$('#primary_nav_five').slideUp(500, function() {});
	$('#primary_nav_six').slideUp(500, function() {});
	$('#primary_nav_seven').slideUp(500, function() {});
	$('.rotator').slideUp(500, function() {});
	$('.toprotator').slideUp(500, function() {});
	$('.toprotatorspacer').slideUp(500, function() {});
	$('#backbutton').show();
}

//////////////////////////////
//sidebar rotator stuff here//
//////////////////////////////

function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('.rotator ul li.show')?  $('.rotator ul li.show') : $('.rotator ul li:first'));

    if ( current.length == 0 ) current = $('.rotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('.rotator ul li:first') :current.next()) : $('.rotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};


//////////////////////////////
//top rotator stuff here//////
//////////////////////////////

function thetopRotator() {
	//Set the opacity of all images to 0
	$('div.toprotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.toprotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('topRotate()',3000);
	
}

function topRotate() {	
	//Get the first image
	var current = ($('.toprotator ul li.show')?  $('.toprotator ul li.show') : $('.toprotator ul li:first'));

    if ( current.length == 0 ) current = $('.toprotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('.toprotator ul li:first') :current.next()) : $('.toprotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
        //var rndNum = Math.floor(Math.random() * sibs.length );
        //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

/////////////
//theming ///
/////////////

function negativetheme(){
	$('.wrapper')
		.css('backgroundColor', '#fff');
		
	$('body')
		.css('backgroundColor', '#fff');
		
	$('#searchbox')
		.css('backgroundColor', '#fff')
		.css('color', '#fc9');
		
	$('h1.blocktitle.gray')
		.css('color', '#FFFFFF')
		.css('backgroundColor', '#18345B');
		
	$('.blocktext')
		.css('borderColor', '#18345B')
		.css('backgroundColor', '#e3e3e3')
		.css('color', '#000000');
		
	$('.staticblocktext')
		.css('borderColor', '#18345B')
		.css('backgroundColor', '#e3e3e3')
		.css('color', '#000000');
		
	$('#fatfooterblock')
		.css('backgroundColor', '#8DBEE2')
		.css('borderColor', '#fff');
		
	$('.fatfooterleft a')
		.css('color', '#000');
		
	$('#submit')
		.attr("src", "images/find2.png");
		
	$('.bannerleft')
	.css('backgroundColor', '#fff');
		
	$('.bannerleft img')
		.attr("src", "images/orangebadge.png");
	
	$('.bannerright')
		.css('paddingBottom', '15px')
		.css('paddingRight', '15px')
		.css('marginBottom', '15px')
		.css('marginTop', '20px')
		.css('height', '70px')
		.css('backgroundColor', '#f97f06');
	
	$('.bannerright a')
		.css('position', 'relative')
		.css('bottom', '18px');
		
	$('.toprotatorspacer')
    	.css('backgroundColor', '#FFFFFF');
}

function normaltheme(){
	$('.wrapper')
		.css('backgroundColor', '#fff');
		
	$('body')
		.css('backgroundColor', '#fff');
		
	$('#searchbox')
		.css('backgroundColor', '#fff')
		.css('color', '#fc9');
		
	$('h1.blocktitle.gray')
		.css('color', '#000000')
		.css('backgroundColor', '#CCC');
		
	$('.blocktext')
		.css('borderColor', '#CCC')
		.css('backgroundColor', '#E6F7FC')
		.css('color', '#000000');
		
	$('.staticblocktext')
		.css('borderColor', '#CCC')
		.css('backgroundColor', '#E6F7FC')
		.css('color', '#000000');
		
	$('#fatfooterblock')
		.css('backgroundColor', '#525252')
		.css('borderColor', '#fff');
		
	$('#submit')
		.attr("src", "images/find.png");
		
	$('.bannerleft')
	.css('backgroundColor', '#fff');
		
	$('.bannerleft img')
		.attr("src", "images/graybadge.png");
	
	$('.bannerright')
		.css('paddingBottom', '0px')
		.css('paddingRight', '0px')
		.css('marginBottom', '0px')
		.css('marginTop', '0px')
		.css('height', '100px')
		.css('backgroundColor', '#fff');
	
	$('.bannerright a')
		.css('position', 'relative')
		.css('bottom', '0px');
		
	$('.toprotatorspacer')
    	.css('backgroundColor', '#FFFFFF');
}


function orangetheme(){	
	$('.wrapper')
		.css('backgroundColor', '#DEE7CA');
		
	$('body')
		.css('backgroundColor', '#DEE7CA');
		
	$('#searchbox')
		.css('backgroundColor', '#DEE7CA')
		.css('color', '#525252');
			
	$('h1.blocktitle.gray')
		.css('color', '#FFFFFF')
		.css('backgroundColor', '#33D5EC');
		
	$('.blocktext')
		.css('borderColor', '#33D5EC')
		.css('backgroundColor', '#fff')
		.css('color', '#000000');
		
	$('.staticblocktext')
		.css('borderColor', '#33D5EC')
		.css('backgroundColor', '#fff')
		.css('color', '#000000');
		
	$('#fatfooterblock')
		.css('backgroundColor', '#525252')
		.css('borderColor', '#DEE7CA');
		
	$('.fatfooterleft a')
		.css('color', '#fff');
		
	$('#submit')
		.attr("src", "images/find3.png");
		
	$('.bannerleft')
	.css('backgroundColor', '#DEE7CA');
		
	$('.bannerleft img')
		.attr("src", "images/bluebadge.png");
	
	$('.bannerright')
		.css('paddingBottom', '15px')
		.css('paddingRight', '15px')
		.css('marginBottom', '15px')
		.css('marginTop', '20px')
		.css('height', '70px')
		.css('backgroundColor', '#33D5EC');
	
	$('.bannerright a')
		.css('position', 'relative')
		.css('bottom', '18px');
		
	$('.toprotatorspacer')
    	.css('backgroundColor', '#DEE7CA');
}

 

